package com.yuan.fmmall.controller;

import com.yuan.fmmall.service.UserService;
import com.yuan.fmmall.utils.Base64Utils;
import com.yuan.fmmall.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Yuan
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户接口")
@CrossOrigin    //用于跨域请求
public class userController {

    @Resource
    private UserService us;

    @ApiOperation("用户登录")
    @GetMapping("/login")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",dataType = "String",value = "登录用户名",required = true),
            @ApiImplicitParam(name = "pwd",dataType = "String",value = "登录密码",required = true)
    })
    public ResultVO login(String name,String pwd){
        ResultVO resultVO = us.checkLogin(name,pwd);
        return resultVO;
    }


    @ApiOperation("用户注册接口")
    @PostMapping("/regist")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",dataType = "String",value = "注册的用户名",required = true),
            @ApiImplicitParam(name = "pwd",dataType = "String",value = "注册的密码",required = true)
    })
    public ResultVO regist(String name,String pwd){
        return us.userRegist(name, pwd);
    }

}
